package org.common.configuration;

import org.common.enums.ExchangeEnum;
import org.common.enums.QueueEnum;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
*@author LSY
*Time: 2018年12月29日上午10:38:02
*
*
*/
@Configuration
public class UserRegisterQueueConfiguration {

	/**
	 * 配置路由交换对象
	 * @return
	 */
	@Bean
	public DirectExchange userRegisterQueueExchange() {
		return new DirectExchange(ExchangeEnum.USER_REGISTER.getValue());
	}
	@Bean
	public Queue userRegisterQueue() {
		return new Queue(QueueEnum.USER_REGISTER.getName(),true);
	}
	
	@Bean
	public Binding userRegisterBinding() {
		return BindingBuilder.bind(userRegisterQueue()).to(userRegisterQueueExchange())
				.with(QueueEnum.USER_REGISTER.getRootingKey());
	}
}
